Skip to content

feat: package DeepSeek V4.1 Flash operators for Ascend. - #2960

Open
PixelFlat wants to merge 6 commits into
xLLM-AI:mainfrom
PixelFlat:codex/feat/v41-ascend-kernel-package
Open

PixelFlat wants to merge 6 commits into
xLLM-AI:mainfrom
PixelFlat:codex/feat/v41-ascend-kernel-package

Conversation

@PixelFlat

@PixelFlat PixelFlat commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Scope

This operator prerequisite is split out of #2844. It packages the Ascend A3 operators needed by DeepSeek V4.1 Flash that are outside the external CANN interfaces in #2950. Model integration, Python ACL Graph and the embedded fixed-step DSpark draft will follow after this operator PR lands.

Backend Operators in this PR
AscendC / ACLNN Paged INT8 candidate QLI V2/V3, device-generated QLI metadata, delayed HC pre, RMSNormCast, and the fused MoE dispatch/FFN/combine binding
TileLang JIT Partial RoPE, SWA RoPE and KV write, index-key transform, INT8 index-query quantization, and C2 pool/norm for prefill and decode
Triton SWA metadata and packing, packed projection split, and Engram hash, history update, quantized lookup and gating

CANN interfaces from #2950

  • refactor: integrate cann9.3 ops-transformer operators into xllm-kernel. #2950 landed in 57e01c16a and provides the generic sparse_flash_mla, sparse_flash_mla_metadata, quant_lightning_indexer_v2 and quant_lightning_indexer_v2_metadata operations. The model will use its external MLA and matching metadata together. The merged provider uses the cann_ops_transformer package and matching OPP in the CANN 9.3 environment.
  • This PR packages the xllm-ops candidate indexer. Its V2 Python and Torch names are quant_lightning_indexer_v2_va and quant_lightning_indexer_v2_metadata_va. V2 VA returns selected token IDs and candidate block IDs. V3 also produces valid block counts consumed by the sparse metadata and indexer on device.
  • 6fbebc8e3 removes the local MLA device sources, AICPU metadata, native binding, registration and build rules. QLI retains its own AICPU metadata. This PR uses the existing third_party/xllm_ops revision.

Validation

On the rebased head, the SDK-free kernel package build, kernel selection (24 passed), changed-file pre-commit hooks and git diff --check passed. The combined catalog contains 112 unique operation names. The four generic MLA/QLI V2 entries resolve to the external backend declarations and the four candidate QLI entries resolve to this PR's AscendC backend declarations.

A3 results before the CANN 9.3 rebase

  • python setup.py build passed on Ascend A3 with CANN 9.0, using a fresh AscendC vendor build directory. The resulting vendor library exports the candidate QLI V3 and sparse metadata entry points and contains no private SparseFlashMla implementation.
  • 44 NPU tests passed across the candidate indexer, TileLang, hyper-connection and normalization suites. QLI checks include non-compact KV and scale pages, source-to-consumer device counts and one ACL Graph replayed with 64, 0, 128 and 64 valid candidate blocks. 24 kernel-selection tests passed.
  • Combined the changes with refactor: integrate cann9.3 ops-transformer operators into xllm-kernel. #2950 at b4f0d976e. All 110 operation names in the combined catalog are unique. The four generic names resolve to the external CANN callables, and the four candidate QLI names resolve to the package's native bindings. One ACL Graph ran candidate generation, sparse QLI selection and the external CSA attention together at device KV lengths of 1,024, 768 and 1,024. It returned 512 distinct valid token IDs and matched the reference attention result on all three replays.
  • Tested the external MLA through refactor: integrate cann9.3 ops-transformer operators into xllm-kernel. #2950 on A3 with a wheel built from ops-transformer@814116886 and its compatible OPP runtime. The older wheel in the A3 development image lacks the mla_prolog export checked during refactor: integrate cann9.3 ops-transformer operators into xllm-kernel. #2950 provider initialization. All nine BF16 SWA/CSA shapes matched the previous package's full outputs bit-for-bit. Each graph captures metadata generation and attention together. Replaying with device KV lengths of 4,097 and 16,384 matched eager execution and sampled FP32 attention references. A separate six-query private SWA test varied the valid count for each row across replays (128, 64, then 128). For a model without a learned sink, the caller supplied an FP32 -inf per query head, preserving the previous softmax result. The follow-up model PR needs to carry this convention into its adapter.

MLA provider comparison

Same A3 device, 16,384-token context, 16 query heads, one KV head, head dimension 512, page size and sliding window 128, compressed TopK 512. Each value is the mean of two run medians in microseconds. The provider order was external / previous / previous / external. Each run timed 21 warmed ACL Graph replays of four successive metadata-plus-attention calls, normalized per call. The table reports operator timing. End-to-end serving performance belongs to the model integration PR.

Shape Previous packaged MLA (µs) External MLA from #2950 (µs)
SWA, B8 Q1 78.07 74.30
CSA1, B8 Q1 97.44 92.45
CSA2, B8 Q1 97.55 92.23
SWA, B8 Q6 85.37 80.45
CSA1, B8 Q6 130.78 126.38
CSA2, B8 Q6 131.00 128.82
SWA, B1 Q1024 131.43 128.41
CSA1, B1 Q1024 1160.47 1106.96
CSA2, B1 Q1024 1157.42 1102.20

A3 QLI consumer timing

Device P50 in microseconds for one metadata operation and one INT8 indexer, timed together inside an ACL Graph. Each of eight requests sees 16,384 keys. TopK is 512 and each candidate block covers eight keys. Both paths selected the expected token IDs. Each sample contains four repetitions, with 21 timed samples after warmup.

Queries per request Valid candidate blocks per row V2 with block IDs (µs) V3 with block IDs and counts (µs)
1 64 99.52 88.40
1 256 98.26 98.84
6 64 142.90 98.74
6 256 145.02 127.26

wai-bao
wai-bao previously approved these changes Dec 4, 2026
@PixelFlat
PixelFlat force-pushed the codex/feat/v41-ascend-kernel-package branch from bb7ac3a to 6fbebc8 Compare December 4, 2026 10:00

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename to deepseek_v41_quant_indexer.cpp

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants